package net.ocps.htc.SpeedReactor;

import net.ocps.htc.SpeedReactor.screens.GameScreen;
import net.ocps.htc.SpeedReactor.screens.Screen;
import net.ocps.htc.SpeedReactor.screens.SplashScreen;

import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;

public class SpeedReactor implements ApplicationListener {
	
	private Screen screen;
	private final Input input = new Input();
	private final boolean started = false;
	private float accum = 0;
	private float aspectRaction = 1280.0f / 720.0f;
	
	@Override
	public void create() {	
		Art.load();
		Sound.load();
		Gdx.input.setInputProcessor(input);
		setScreen(new SplashScreen());
	}

	@Override
	public void resize(int width, int height) {
//		aspectRatio = (float) width / (float) height;
	}

	@Override
	public void render() {
		Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
		accum += Gdx.graphics.getDeltaTime();
		while(accum > 1.0f / 60.0f) {
			screen.tick(input);
			input.tick();
			accum -= 1.0f / 60.0f;
		}
		screen.render();
		
	}

	@Override
	public void pause() {
	}

	@Override
	public void resume() {
	}

	@Override
	public void dispose() {
	}

	public void setScreen(Screen nScreen) {
		if (screen != null) screen.removed();
		screen = nScreen;
		if (screen != null) screen.init(this);
	}


}
